package com.game.sprite;

import android.graphics.Bitmap;
import android.graphics.Canvas;

/**
 * @author Harmonia Game Studio
 *
 */
public class Sprite {

	/**
	 * 
	 */
	protected Bitmap bitmap;
	
	/**
	 * 
	 */
	protected int x;			
	
	/**
	 * 
	 */
	protected int y;			
	
	/**
	 * 
	 */
	protected boolean touched;	
	
	/**
	 * 
	 * @param bitmap
	 * @param x
	 * @param y
	 */
	public Sprite(Bitmap bitmap, int x, int y) 
	{
		//
		this.bitmap = bitmap;
		
		//
		this.x = x;
		
		//
		this.y = y;
	}
	
	//saco de gets e sets...
	
	/**
	 * 
	 * @return
	 */
	public Bitmap getBitmap() 
	{
		//
		return bitmap;
	}
	
	/**
	 * 
	 * @param bitmap
	 */
	public void setBitmap(Bitmap bitmap)
	{
		//
		this.bitmap = bitmap;
	}
	
	/**
	 * 
	 * @return
	 */
	public int getX()
	{
		//
		return x;
	}
	
	/**
	 * 
	 * @param x
	 */
	public void setX(int x)
	{
		//
		this.x = x;
	}
	
	/**
	 * 
	 * @return
	 */
	public int getY()
	{
		//
		return y;
	}
	
	/**
	 * 
	 * @param y
	 */
	public void setY(int y) 
	{
		//
		this.y = y;
	}

	/**
	 * 
	 * @return
	 */
	public boolean isTouched()
	{
		//
		return touched;
	}

	/**
	 * 
	 * @param touched
	 */
	public void setTouched(boolean touched) 
	{
		//
		this.touched = touched;
	}
	
	/**
	 * 
	 * @param canvas
	 */
	public void draw(Canvas canvas)
	{
		//
		canvas.drawBitmap(bitmap, x - (bitmap.getWidth() / 2), y - (bitmap.getHeight() / 2), null);
	}

	/**
	 * 
	 * @param eventX
	 * @param eventY
	 */
	public void handleActionDown(int eventX, int eventY)
	{
		//
		if (eventX >= (x - bitmap.getWidth() / 2) && (eventX <= (x + bitmap.getWidth()/2)))
		{
			//
			if (eventY >= (y - bitmap.getHeight() / 2) && (y <= (y + bitmap.getHeight() / 2)))
			{
				//
				setTouched(true);
			}
			//
			else
			{
				//
				setTouched(false);
			}
		}
		//
		else
		{
			//
			setTouched(false);
		}
	}
}
